from bs4 import BeautifulSoup
import requests
from lxml import etree
import time

base_url = 'https://www.kuaidaili.com/free/inha/{}/'.format(1)
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
    'Accept':'application/json, text/plain, */*',
    'Content-Type': 'application/json; charset=utf-8'
    }

# 发送请求：模拟浏览器发送请求，获取响应数据
response = requests.get(base_url,headers=headers)
# 解码响应内容
html_data = response.content.decode('utf-8')

# 指定 HTML 文件的路径
html_file_path = 'example.html'

# 打开文件并写入内容
with open(html_file_path, 'w', encoding='utf-8') as file:
    file.write(html_data)
